home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / libs / intuisup.lha / Intuisup / source.lha / Editor / main.c < prev    next >
C/C++ Source or Header  |  1992-10-05  |  6KB  |  220 lines

  1. /* $Revision Header *** Header built automatically - do not edit! ***********
  2.  *
  3.  *    (C) Copyright 1991 by Torsten Jürgeleit
  4.  *
  5.  *    Name .....: main.c
  6.  *    Created ..: Sunday 22-Dec-91 21:22:47
  7.  *    Revision .: 2
  8.  *
  9.  *    Date        Author                 Comment
  10.  *    =========   ====================   ====================
  11.  *    02-Oct-92   Michael Bjerking       New realese, better Screen/Window editor
  12.  *    02-Oct-92   Michael Bjerking       Arp library replaced by ReqTools
  13.  *    22-Dec-91   Torsten Jürgeleit      Created this file!
  14.  *
  15.  ****************************************************************************
  16.  *
  17.  *    Main part
  18.  *
  19.  * $Revision Header ********************************************************/
  20.  
  21.  /* Includes */
  22.  
  23. #include "includes.h"
  24. #include "defines.h"
  25. #include "imports.h"
  26. #include "protos.h"
  27.  
  28.  /* Globals */
  29.  
  30. struct IntuitionBase *IntuitionBase;
  31. struct GfxBase *GfxBase;
  32. struct ArpBase *ArpBase;
  33. struct Library *IntuiSupBase = NULL;    /* Clear for show_error() */
  34. struct ReqToolsBase *ReqToolsBase;
  35.  
  36. /*
  37. struct Library        *DiskfontBase;
  38. struct Library        *LayersBase;
  39. */
  40.  
  41. struct Screen wb_screen;
  42. struct Window *ewin, *pwin;
  43. struct TextAttr topaz60_attr =
  44. {(STRPTR) "topaz.font", TOPAZ_SIXTY,
  45.  FS_NORMAL, FPF_ROMFONT}, topaz80_attr =
  46. {
  47.     (STRPTR) "topaz.font", TOPAZ_EIGHTY,
  48.     FS_NORMAL, FPF_ROMFONT
  49. };
  50. STATIC struct NewWindow editor_new_window =
  51. {
  52.     EDITOR_WINDOW_LEFT, EDITOR_WINDOW_TOP, EDITOR_WINDOW_WIDTH,
  53.     EDITOR_WINDOW_HEIGHT, EDITOR_WINDOW_DETAIL_PEN, EDITOR_WINDOW_BLOCK_PEN,
  54.     EDITOR_WINDOW_IDCMP, EDITOR_WINDOW_FLAGS, NULL, NULL,
  55.     (UBYTE *) & editor_window_title[0], NULL, NULL, 0, 0, 0, 0, WBENCHSCREEN
  56. };
  57. struct NewWindow project_new_window =
  58. {
  59.     0, 0, 0, 0, PROJECT_WINDOW_DETAIL_PEN, PROJECT_WINDOW_BLOCK_PEN,
  60.     PROJECT_WINDOW_IDCMP, PROJECT_WINDOW_FLAGS, NULL, NULL,
  61.     PROJECT_WINDOW_TITLE, NULL, NULL, PROJECT_WINDOW_MIN_WIDTH,
  62.     PROJECT_WINDOW_MIN_HEIGHT, -1, -1, WBENCHSCREEN
  63. };
  64.  
  65. struct TemplateList template_list;
  66. struct Template *selected_template, *info_template;
  67. struct Box current_box;
  68.  
  69. struct GadgetData *use_gd;
  70. struct rtFileRequester *project_file_requester, *csource_file_requester;
  71.  
  72. struct Dimension min_dimension[MAX_TEMPLATE_TYPES] =
  73. {
  74.     {20, 10},
  75.     {0, 0},
  76.     {20, 10},
  77.     {21, 11},
  78.     {50, 10},
  79.     {30, 8},
  80.     {30, 8},
  81.     {20, 8},
  82.     {20, 8},
  83.     {50, 10},
  84.     {40, 10},
  85.     {40, 30},
  86.     {60, 30}};
  87.  
  88. APTR eri, pri, egl, eml, use_gl;
  89.  
  90. BYTE *default_mx_text_array[]=
  91. {"MX1", "MX2", NULL}, *default_cycle_text_array[]=
  92. {"Cycle", "Test 1", "Test 2", NULL}, *default_listview_text_array[]=
  93. {"Entry 1", "Entry 2", "Entry 3",
  94.  "Entry 4", "Entry 5", "Entry 6", "Entry 7", "Entry 8",
  95.  "Entry 9", "Entry 10", NULL};
  96. BYTE editor_window_title[MAX_PROJECT_NAME_LEN + 3], editor_screen_title[MAX_PROJECT_NAME_LEN + 1], project_window_title[80];
  97.  
  98. USHORT snap_offset_table[]=
  99. {1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20};
  100.  
  101. USHORT editor_mode = DEFAULT_EDITOR_MODE, snap_offset = DEFAULT_SNAP_OFFSET, template_type = DEFAULT_TEMPLATE_TYPE;
  102.  
  103. USHORT modify_mode = 0, mouse_button = 0;
  104. SHORT last_snap_x, last_snap_y;
  105.  
  106. BOOL info_displayed = FALSE;
  107.  
  108.  /* Main routine */
  109.  
  110. LONG
  111. main(VOID)
  112. {
  113.     LONG return_code = RETURN_ERROR;
  114.  
  115.     MWInit((BPTR) NULL, (LONG) MWF_NOATRASH);
  116.     if (IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 0L))
  117.     {
  118.         if (GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 0L))
  119.         {
  120.             if (!(ReqToolsBase = (struct ReqToolsBase *) OpenLibrary(REQTOOLSNAME, REQTOOLSVERSION)))
  121.                 show_error(EDITOR_ERROR_NO_REQTOOLS);
  122.             else
  123.             {
  124.                 if (!(IntuiSupBase = (struct Library *) OpenLibrary(IntuiSupName, IntuiSupVersion)))
  125.                     show_error(EDITOR_ERROR_NO_INTUISUP);
  126.                 else
  127.                 {
  128.                     return_code = init_resources();
  129.                     CloseLibrary(IntuiSupBase);
  130.                 }
  131.                 CloseLibrary((struct Library *) ReqToolsBase);
  132.             }
  133.             CloseLibrary((struct Library *) GfxBase);
  134.         }
  135.         CloseLibrary((struct Library *) IntuitionBase);
  136.     }
  137.     MWTerm();
  138.  
  139.     return (return_code);
  140. }
  141.  
  142.  /* Init resources */
  143.  
  144. LONG
  145. init_resources(VOID)
  146. {
  147.     SHORT status;
  148.     LONG return_code = RETURN_OK;
  149.  
  150.     GetScreenData((BYTE *) & wb_screen, (LONG) sizeof(struct Screen), (LONG)
  151.                   WBENCHSCREEN, (struct Screen *) NULL);
  152.     /* Init and open editor window */
  153.     if (!(eri = IGetRenderInfo((struct Screen *) NULL,
  154.                                EDIT_RENDER_INFO_FLAGS)))
  155.     {
  156.         status = EDITOR_ERROR_OUT_OF_MEM;
  157.     }
  158.     else
  159.     {
  160.         editor_new_window.LeftEdge = (wb_screen.Width -
  161.                                       editor_new_window.Width) / 2;
  162.         if (!(ewin = IOpenWindow(eri, &editor_new_window,
  163.                                  EDIT_OPEN_WINDOW_FLAGS)))
  164.         {
  165.             status = EDITOR_ERROR_NO_WINDOW;
  166.         }
  167.         else
  168.         {
  169.  
  170.             /* Init Template IDCMP flag */
  171.             template_list.tl_IDCMPFlags = EDITOR_WINDOW_IDCMP;
  172.  
  173.             /* Init and open project window */
  174.             pri = NULL;
  175.             pwin = NULL;
  176.             if ((status = new_project_window(&template_list,
  177.                                              TEMPLATE_LIST_FLAG_DEFAULT_WINDOW)) == EDITOR_STATUS_NORMAL)
  178.             {
  179.  
  180.                 /* Init ReqTools file requester structs */
  181.                 if (!(project_file_requester = (struct rtFileRequester *)rtAllocRequestA(RT_FILEREQ, NULL)))
  182.                 {
  183.                     status = EDITOR_ERROR_OUT_OF_MEM;
  184.                 }
  185.                 else
  186.                 {
  187.                     if (!(csource_file_requester = (struct rtFileRequester *)rtAllocRequestA(RT_FILEREQ, NULL)))
  188.                     {
  189.                         status = EDITOR_ERROR_OUT_OF_MEM;
  190.                     }
  191.                     else
  192.                     {
  193.                         status = editor_action_loop();
  194.                     }
  195.                 }
  196.             }
  197.             rtFreeRequest((APTR)project_file_requester);
  198.             rtFreeRequest((APTR)csource_file_requester);
  199.  
  200.             /* Free resources */
  201.             if (pwin)
  202.             {
  203.                 ICloseWindow(pwin, FALSE);
  204.             }
  205.             if (pri)
  206.             {
  207.                 IFreeRenderInfo(pri);
  208.             }
  209.             ICloseWindow(ewin, FALSE);
  210.         }
  211.         IFreeRenderInfo(eri);
  212.     }
  213.     if (status < EDITOR_STATUS_NORMAL)
  214.     {
  215.         show_error(status);
  216.         return_code = RETURN_ERROR;
  217.     }
  218.     return (return_code);
  219. }
  220.